import request from '@/utils/request'

const userUrl = '/sysUser/v1';
const roleUrl = '/sysRole/v1';
const menuUrl = '/sysMenu/v1';
const dictUrl = '/sysParameter/v1';
const dictSubUrl = '/sysParameters/v1';

/**** 参数管理相关api ***/
export function getDictLists() {
    return request({
        url: `${dictUrl}/all`,
        method: 'GET',
    });
}
export function dictSave(data) {
    return request({
        url: `${dictUrl}/save`,
        method: 'POST',
        data
    });
}

export function dictDel(id) {
    return request({
        url: `${dictUrl}/del/${id}`,
        method: 'POST',
    });
}

export function dictSearch(data) {
    return request({
        url: `${dictUrl}/list`,
        method: 'GET',
        params: data
    });
}

export function dictSubSearch(data) {
    return request({
        url: `${dictSubUrl}/list`,
        method: 'GET',
        params: data
    });
}

export function dictSubSave(data) {
    return request({
        url: `${dictSubUrl}/save`,
        method: 'POST',
        data
    });
}

export function dictSubDel(id) {
    return request({
        url: `${dictSubUrl}/del/${id}`,
        method: 'POST',
    });
}




/**** 查询菜单列表 ***/
export function treeMenu(query) {
    return request({
        url: `${menuUrl}/tree`,
        method: 'GET',
        params: query
    })
}

export function menuSave(data) {
    return request({
        url: `${menuUrl}/save`,
        method: 'POST',
        data
    })
}

export function menuSearch(query) {
    return request({
        url: `${menuUrl}/list/table`,
        method: 'GET',
        params: query
    });
}
export function menuDel(id) {
    return request({
        url: `${menuUrl}/del/${id}`,
        method: 'POST',
    });
}

// 查询登录的用户信息及所拥有的菜单按钮权限数据
export function getMenuUser(userId , accountType) {
    return request({
        url: `${menuUrl}/user`,
        method: 'GET',
        params: {
            userId,
            accountType,
        }
    });
}



/**** 角色相关api ***/
export function roleSave(data) {
    return request({
        url: `${roleUrl}/save`,
        method: 'POST',
        data
    });
}

//删除角色
export function roleDel(id) {
    return request({
        url: `${roleUrl}/del/${id}`,
        method: 'POST',
    });
}

export function roleSearch(data) {
    return request({
        url: `${roleUrl}/list`,
        method: 'GET',
        params: data
    });
}
export function roleAll() {
    return request({
        url: `${roleUrl}/all`,
        method: 'GET'
    });
}

export function roleMenuSave(data) {
    return request({
        url: `${roleUrl}/menu/save`,
        method: 'POST',
        data
    });
}


/**** 用户相关api ***/
export function userSave(data) {
    return request({
        url: `${userUrl}/save`,
        method: 'POST',
        data
    });
}

export function userDel(id) {
    return request({
        url: `${userUrl}/del/${id}`,
        method: 'POST',
    });
}

export function userSearch(data) {
    return request({
        url: `${userUrl}/list`,
        method: 'GET',
        params: data
    });
}
